package com.books.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class TimeAspect {

    @Around("execution(* com.books.controller.*.*(..))")
public Object timeRecord(ProceedingJoinPoint pjp) throws Throwable {
    long start=System.currentTimeMillis();
    Object result= pjp.proceed();
long end=System.currentTimeMillis();
log.info(pjp.getStaticPart()+"执行耗时： {}ms",end-start);
return result;
}
}
